package trefliq.EJB.entities;

import java.io.Serializable;
import javax.persistence.*;

/**
 *
 * @author Brandon
 */
@Entity
@NamedQueries({
    @NamedQuery(name = "CartItem.findAll", query = "SELECT c FROM CartItem c"),
    @NamedQuery(name = "CartItem.findById", query = "SELECT c FROM CartItem c WHERE c.id = :id"),
    @NamedQuery(name = "CartItem.findByMovie", query = "SELECT c FROM CartItem c WHERE c.cartid = :cartid")
})
public class CartItem implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @JoinColumn(name = "MOVIEID", referencedColumnName = "ID", nullable = false)
    @ManyToOne(optional = false)
    private Movie movieid;
    @JoinColumn(name = "CARTID", referencedColumnName = "ID", nullable = false)
    @ManyToOne(optional = false)
    private Cart cartid;
    
    public CartItem() { 
        
    }
    
    public CartItem(Cart cartid) { 
       this.cartid = cartid; 
    }
    
    public CartItem(Movie movie) { 
        movieid = movie; 
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Cart getCartid() {
        return cartid;
    }

    public void setCartid(Cart cartid) {
        this.cartid = cartid;
    }

    public Movie getMovieid() {
        return movieid;
    }

    public void setMovieid(Movie movieid) {
        this.movieid = movieid;
    }
       
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CartItem)) {
            return false;
        }
        CartItem other = (CartItem) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "trefliq.EJB.entities.CartItem[ id=" + id + " ]";
    }
    
}